<template>
	<view class="page">
		<view class="top">
			<view class="money">
				{{money}}
			</view>
			<view class="toptitle">
				可提现金额(元)
			</view>
		</view>
		<view class="box">
			<view class="title">
				提现金额
			</view>
			<view class="line">
				<view class="danwei">
					￥
				</view>
				<input type="digit"  v-model="number" placeholder="请输入提现金额"/>
				<view class="allbtn" @click="allmoney">
					全部金额
				</view>
			</view>
			<view class="pagebtn" @click="tixian">
				提交
			</view>
		</view>
	</view>
</template>

<script>
	import {applyWithdraw} from '../../utils/api.js'
	export default {
		data() {
			return {
				money:'',
				number:''
			}
		},
		onLoad(e) {
			this.money=e.money
			
		},
		methods: {
			
			allmoney(){
				this.number=this.money
			},
			tixian(){
				if(this.number==''){
					uni.showToast({
						title: '请输入提现金额',
						icon:'none',
						duration: 2000
					});
					return
				}
				if(this.money!=''&& Number(this.number)>Number(this.money)){
					uni.showToast({
						title: '超出总额',
						icon:'none',
						duration: 2000
					});
					return
				}
				let p={
					phone:uni.getStorageSync('phone'),
					price:this.number
				}
				applyWithdraw(p).then(res=>{
					console.log(res)
					if(res.data.code==200){
						uni.showToast({
							title: '提现申请成功',
							icon:'none',
							duration: 2000
						});
						setTimeout(()=>{
							uni.navigateBack()
						},2000)
					}else{
						uni.showToast({
							title: res.data.msg,
							icon:'none',
							duration: 2000
						});
					}
				})
			},
		}
	}
</script>

<style lang="less" scoped>
  .page{
	  width: 750rpx;
	  box-sizing: border-box;
	  .top{
		  width: 100%;
		  height: 300rpx;
		  background-color: #1a4f8a;
		color: white;
	    text-align: center;
		padding-top: 40rpx;
		.money{
			font-size: 36rpx;
			font-weight: bold;
		}
		.toptitle{
			font-size: 30rpx;
			margin-top: 20rpx;
		}
	  }
	  .box{
		  background-color: white;
		  width: 100%;
		  border-radius: 30rpx;
		  z-index: 999;
		  margin-top: -30rpx;
		  box-sizing: border-box;
		  padding: 20rpx;
		  .title{
			  font-weight: bold;
			  line-height: 3;
		  }
		  .line{
			  width: 100%;
			  display: flex;
			  align-items: center;
			  justify-content: space-evenly;
			  height: 50rpx;
			  line-height: 50rpx;
			  .danwei{
				  font-size: 40rpx;
				  font-weight: bold;
			  }
			  input{
				  width:70% ;
				  height: 50rpx;
				 box-sizing: border-box;
				 padding: 0 20rpx;
				 line-height: 70rpx;
				 font-weight: bold;
				  
				  
			  }
			  .allbtn{
				  width: 150rpx;
				  height: 70rpx;
				  line-height: 70rpx;
				  text-align: center;
				  font-size: 30rpx;
				  background-color: #c1c1c1;
			  }
		  }
		  .pagebtn{
			  width: 90%;
			  height: 70rpx;
			  text-align: center;
			  line-height: 70rpx;
			  text-align: center;
			  font-size: 30rpx;
			  background-color: #1a4f8a;
			color: white;
			border-radius: 35rpx;
			margin: 50rpx auto;
		  }
	  }
	  
  }
</style>
